package com.example.demo.controller;

import com.example.demo.entity.Person;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import java.util.ArrayList;
import java.util.List;

/**
 * @创建者：zzw
 * @创建时间 2018/7/3 0003
 * @描述
 */
@Controller
public class PersonController {
    @RequestMapping(value = "/person",method = RequestMethod.GET)
    public String index(Model model){
        Person person = new Person("aa",11);

        List<Person> people = new ArrayList<>();
        Person p1 = new Person("xx",12);
        Person p2 = new Person("yy",13);
        Person p3 = new Person("zz",14);
        people.add(p1);
        people.add(p2);
        people.add(p3);

        model.addAttribute("singlePerson",person);
        model.addAttribute("people",people);
        return "index";
    }
}
